//
//  GYNotDisturbViewController.m
//  Visitor
//
//  Created by x on 2017/9/20.
//  Copyright © 2017年 HLB. All rights reserved.
//

#import "GYNotDisturbViewController.h"
#import "GYNotDisturbCell.h"
#import "GYNotDisturbReasonCell.h"
#import "GYAddNotDisturbViewController.h"

@interface GYNotDisturbViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;

/** 标题数组 */
@property (nonatomic, strong) NSMutableArray *titles;
@end

@implementation GYNotDisturbViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setupUI];
    
}
- (void)setupUI {
    self.title = @"免打扰模式";
    self.tableView.sectionHeaderHeight = 10;
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(rightBarButtonClick)];
}

- (void)rightBarButtonClick {
    GYAddNotDisturbViewController *addController = [[GYAddNotDisturbViewController alloc] initWithNibName:@"GYAddNotDisturbViewController" bundle:nil];
    [self.navigationController pushViewController:addController animated:YES];
}

#pragma  mark -- <UITableViewDelegate,UITableViewDataSource>

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return section == 0 ? 1 : self.titles.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        GYNotDisturbCell *cell = [GYNotDisturbCell cellWithTbaleView:tableView];
        return cell;
    }else {
        GYNotDisturbReasonCell *cell = [GYNotDisturbReasonCell cellWithTableView:tableView];
        cell.title = self.titles[indexPath.row];
        return cell;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 50;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 10)];
    view.backgroundColor = [UIColor clearColor];
    
    return view;
}

#pragma mark -- 懒加载

- (NSMutableArray *)titles
{
    if (!_titles) {
        _titles = [NSMutableArray arrayWithObjects:@"会议",@"下班",@"午休", nil];
    }
    return _titles;
}


@end
